package org.linys.dao.dict;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.linys.model.dict.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@SuppressWarnings("unchecked")
@Repository
public class GoodsDAO {
	private SqlSession sqlSession;
	@Autowired
	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}
	public int count(Goods goods) {
		return (Integer) sqlSession.selectOne("GoodsMapper.count", goods);
	}
	public List<Goods> view(Goods goods, Integer start, Integer rows) {
		return (List<Goods>) sqlSession.selectList("GoodsMapper.view",goods,new RowBounds(start,rows));
	}
	public int save(Goods goods) {
		return sqlSession.insert("GoodsMapper.insert", goods);
	}
	public int update(Goods goods) {
		return sqlSession.update("GoodsMapper.update", goods);
	}
	public int deleteByID(Integer id) {
		return sqlSession.delete("GoodsMapper.deleteByID", id);
	}
	public int countChoose(Goods goods) {
		return (Integer) sqlSession.selectOne("GoodsMapper.countChoose",goods);
	}
	public List<Goods> viewChoose(Goods goods, Integer start, Integer rows) {
		return (List<Goods>) sqlSession.selectList("GoodsMapper.viewChoose",goods,new RowBounds(start,rows));
	}
	public Goods getByID(Goods goods) {
		return (Goods) sqlSession.selectOne("GoodsMapper.getByID", goods);
	}
	
}
